package com.yss.system.api.factory;

import com.yss.common.core.domain.YssResponse;
import com.yss.system.api.RemoteConfigService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;


/**
 * 获取系统参数信息
 */
@Component
public class RemoteConfigFallbackFactory implements FallbackFactory<RemoteConfigService> {
    private static final Logger log = LoggerFactory.getLogger(RemoteConfigFallbackFactory.class);

    @Override
    public RemoteConfigService create(Throwable throwable) {
        log.error("用户服务调用失败:{}", throwable.getMessage());
        return new RemoteConfigService() {
            @Override
            public YssResponse<String> getConfigByKey(String configKey, String source) {
                return YssResponse.fail("获取系统参数信息失败:" + throwable.getMessage());
            }
        };
    }
}
